
//第二题
package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {

	r := rand.New(rand.NewSource(time.Now().UnixNano()))

	var v1 int64 = 0
	var v2 int64 = 1

	var sum []int64
	for i := 0; i < 20; i++ {
		sum = append(sum, int64(r.Intn(20)))
	}

	for k, v := range sum {
		if k%2 == 0 {

			fmt.Printf("偶数的时候对应的数值: %d\n", v)
			v2 = v2 * v

		} else {
			v1 = v1 + v

		}

	}

	fmt.Printf("sum:%v\n", sum)
	fmt.Printf("单数个求和的结果: %v\n", v1)
	fmt.Printf("偶数个求乘积的结果: %v\n", v2)
}